package WaiBao;

import java.util.Arrays;

public class WangYiJie {
    public static void main(String[] args) {
        String[] name= {"李晨(班长)", "李二牛(副班长)", "小李(学习委员)", "张大胖(文艺委员)", "任上兵", "张小嘎", "李晓文", "张大大", "沥青", "杨滴滴", "作文", "王凯星",
                "张和子", "李道伟", "李金城", "张活法", "左岭", "右肩膀", "张小海", "李光洙", "李小海", "张大宇", "刘青玉", "林青霞", "林耀东", "林宗辉", "林总次", "林灿",
                "凌潇潇", "王怡洁(组织委员)"};//考生本人:王怡洁(组织委员)
        int[] age = {21, 21,19,20,22, 21, 21,22,23, 22,19, 21, 21, 19, 19,20, 18, 19, 20, 19, 19,21, 21, 21, 20, 23, 19,22,21, 21};//考生年龄：21岁


        double[] pingban1 = {91, 86, 60, 71, 74, 79, 78, 80, 73, 84, 64, 87, 71, 79, 65, 78, 69, 99, 96, 88, 92, 91, 95, 88, 75, 74, 78, 74, 80, 95};
        double[] pingban2 = {94, 71, 71, 82, 80, 61, 73, 69, 80, 94, 70, 70, 87, 74, 90, 75, 74, 79, 64, 68, 92, 71, 95, 85, 74, 84, 77, 84, 91, 96};
        double[] pingban3 = {84, 78, 74, 83, 71, 61, 68, 80, 84, 60, 63, 80, 75, 75, 65, 68, 69, 69, 96, 93, 92, 81, 95, 95, 79, 84, 77, 71, 89, 96};

        double s1;//代表每个学生的总分
        double s2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            s1 = pingban1[i] + pingban2[i] +pingban3[i];
//            s2 = ( s1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +s1);
//            System.out.println(name[i] + "的平均分为:" +s2);
//        }


        double yaoshi1 = 0,yaoshi2 = 0;
        double[] weisheng = new double[30];
//        for (int i = 0; i < 30; i++) {
//            yaoshi1 = pingban1[i] + pingban2[i] + pingban3[i];
//            yaoshi2= (yaoshi1 * 1.0) / 3;
//            weisheng[i] = yaoshi2;
//        }
//
//        for (int i = 0; i <weisheng.length - 1; i++) {
//            for (int j = 0; j < weisheng.length - i - 1; j++) {
//                if (weisheng[j] < weisheng [j + 1]) {
//                    double tep =weisheng[j];
//                    weisheng[j] =weisheng[j + 1];
//                    weisheng[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(weisheng[i]);
//        }


        double shuirui1 = 0,shuirui2 = 0,shuirui3 = 0;//计算每门课的平均分
        double meiyou1 = 0,meiyou2 = 0, meiyou3 = 0;//计算每门课标准差
        double hetao1 = 0,hetao2 = 0,hetao3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < pingban1.length; i++) {
            sum2+=pingban1[i];
        }
        shuirui1 = (sum2*1.0)/30;
        System.out.println("生物化学的班级平均分为:"+shuirui1);
        double Sum = 0;
        for (int i = 0; i < pingban2.length; i++) {
            Sum+=pingban2[i];
        }
        shuirui2 = (Sum*1.0)/30;
        System.out.println("微生物学的班级平均分为:"+shuirui2);
        double sum = 0;
        for (int i = 0; i <pingban3.length; i++) {
            sum+=pingban3[i];
        }
        shuirui3 = (sum*1.0)/30;
        System.out.println("人体组织解剖学的班级平均分为:"+ shuirui3);



        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < pingban1.length; i++) {
            c1+= (pingban1[i] - shuirui1)*(pingban1[i] -shuirui1);
        }
        meiyou1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:"+meiyou1);

        for (int i = 0; i <pingban2.length; i++) {
            c2+= (pingban2[i] -shuirui2)*(pingban2[i] - shuirui2);
        }
        meiyou2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:"+meiyou2);

        for (int i = 0; i < pingban3.length; i++) {
            c3+= (pingban3[i] -shuirui3)*(pingban3[i] -shuirui3);
        }
        meiyou3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:"+meiyou3);
////////
        Arrays.sort(pingban1);
        Arrays.sort(pingban2);
        Arrays.sort(pingban3);
        hetao1 =(pingban1[14]+pingban1[15])*1.0/2;
        hetao2 =( pingban2[14]+pingban2[15])*1.0/2;
        hetao3 =(pingban3[14]+pingban3[15])*1.0/2;
        System.out.println("生物化学的中位数为:"+hetao1);
        System.out.println("微生物学的中位数为:"+hetao2);
        System.out.println("人体组织解剖学的中位数为:"+hetao3);





    }
}
